// src/lib/utils.ts
export const isFileOrBlob = (value: any): boolean => {
  return (
    value instanceof File ||
    value instanceof Blob ||
    (typeof File !== "undefined" && value instanceof File) ||
    (typeof Blob !== "undefined" && value instanceof Blob)
  );
};

export const sortParams = (params: Record<string, any>): string => {
  return Object.keys(params)
    .sort()
    .map((key) => `${key}=${params[key]}`)
    .join("&");
};

// 简单的MD5实现，建议使用加密库（如crypto-js）
export const md5 = (str: string): string => {
  // 这里需要实现或引入真正的MD5算法
  return btoa(unescape(encodeURIComponent(str))); // 示例代码，需替换
};
